package com.infraware.supermanbooks.book;

import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

/**
 * Helper class for providing sample content for user interfaces created by
 * Android template wizards.
 * <p>
 * TODO: Replace all uses of this class before publishing your app.
 */
public class BookContent {

    /**
     * An array of sample (dummy) items.
     */
    public static List<BookItem> ITEMS = new ArrayList<BookItem>();

    /**
     * A map of sample (dummy) items, by ID.
     */
    public static Map<String, BookItem> ITEM_MAP = new HashMap<String, BookItem>();

    static {
        for (int i = 1; i < 1000; i++) {
            addItem(new BookItem(String.valueOf(i), String.valueOf(i), "Book " + i, "Author " + i));
        }
    }

    public static void addItem(BookItem item) {
        ITEMS.add(item);
        ITEM_MAP.put(item.id, item);
    }

    public static void clear() {
        ITEMS.clear();
        ITEM_MAP.clear();
    }

    /**
     * A dummy item representing a piece of content.
     */
    public static class BookItem {
        public String id;
        public String title;
        public String author;
        public SoftReference<Bitmap> cover;
        public String path;

        public BookItem(String path, String id, String title, String author) {
            this.path = path;
            this.id = id;
            this.title = title;
            this.author = author;
        }
    }
}
